function fnLogin() {
    var u_name = document.getElementById("uname");
    var oError = document.getElementById("error-box1");
    var oError2 = document.getElementById("error-box2");
    var u_pwd = document.getElementById("pwd");
    var isoError = true;
    oError.innerHTML = "<br>";
    oError2.innerHTML = "<br>";


    if (u_name.value.length < 6 || u_name.value.length > 20 || u_name.value == '') {
        oError.innerHTML = "请输入6-20位的用户名";
        isoError = false;
        return;

    }
    if (u_pwd.value.length < 6 || u_pwd.value.length > 16 || u_pwd.value == '') {
        oError2.innerHTML = "请输入6-16位的密码";
        isoError = false;
        return;

    }else{
      var PUBLIC_KEY = '';

      $.ajax({
        type: "GET",
        url: "../publickey",
        dataType: 'json',
        success: function (result) {
          PUBLIC_KEY = result.data; //获取公钥

          var encrypt = new JSEncrypt();
          encrypt.setPublicKey('-----BEGIN PUBLIC KEY-----' + PUBLIC_KEY + '-----END PUBLIC KEY-----');

          // var username = $(".username").val();
          // var encryptusername = encrypt.encrypt(username);
          console.log('前端  0公钥：%o',PUBLIC_KEY);
          console.log('加密后的数据：%o', encrypt);


          var password = $("#pwd").val();
          var encrypted = encrypt.encrypt(password);

          $("#pwd").val(encrypted);

          console.log("登录前端：加密后的密码：" + $("#pwd").val());

          $("#loginForm").submit();


        }
      });





    }


}
